package com.level2app.ui.home;

import android.os.Bundle;

import androidx.recyclerview.widget.GridLayoutManager;

import com.level2app.R;
import com.level2app.adapter.CategoryAllAdapter;
import com.level2app.base.BaseActivity;
import com.level2app.databinding.ActivityCategoryBinding;
import com.level2app.ui.home.view.CategoryViewModel;
import com.level2app.utils.JumpIntent;

import java.util.ArrayList;
import java.util.List;

/**
 * 全部分类
 */
public class CategoryActivity extends BaseActivity<ActivityCategoryBinding, CategoryViewModel> {

    private CategoryAllAdapter topAdapter, bottomAdapter;
    private List<String> topData, bottomData;

    @Override
    protected CategoryViewModel bindModel() {
        return getViewModel(this, CategoryViewModel.class);
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initData() {
        initTitleBar(getString(R.string.categories));
        topAdapter = new CategoryAllAdapter(1);
        binding.hasCateRv.setLayoutManager(new GridLayoutManager(this, 2));
        binding.hasCateRv.setAdapter(topAdapter);
        bottomAdapter = new CategoryAllAdapter(2);
        binding.noHasCateRv.setLayoutManager(new GridLayoutManager(this, 2));
        binding.noHasCateRv.setAdapter(bottomAdapter);

        //TODO：假数据
        topData = new ArrayList<>();
        topData.add("Hotel & Resort");
        topData.add("Grand Openings/\nLaunch Product");
        topData.add("Live Events");
        topData.add("Tourism");
        bottomData = new ArrayList<>();
        bottomData.add("App/Software");
        bottomData.add("Beverages");
        bottomData.add("Certifications/\nEducation");
        bottomData.add("Chiropractor");
        bottomData.add("Day Spa");
        bottomData.add("Chiropractor");
        bottomData.add("Experience");
        bottomData.add("Fitness");
        bottomData.add("Med Spas");
        bottomData.add("Merchandise");
        bottomData.add("Salon");
        bottomData.add("Sports Events");
        bottomData.add("Private Air Travel");
        bottomData.add("Private Sea Travel");

        topAdapter.submitList(topData);
        bottomAdapter.submitList(bottomData);
    }

    @Override
    protected void initClick() {
        super.initClick();
        topAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> {
            //TODO:跳转分类列表页
            Bundle bundle = new Bundle();
            bundle.putString("title", topData.get(i));
            JumpIntent.jump(this, CategoriesListActivity.class, bundle);
        });
    }
}